Let's dive into another great reason
to adopt the Global HTTPS Load Balancer with Cloud Run. Cross regional load balancing, latency
is one of the reasons why you might want to serve your application
in multiple regions. Google Cloud is a collection of data
centers called regions connected by a very fast network. Looking at this latency plot,
you can learn a few things. First, If your users are in Europe,
most regions are very close. Also it doesn't appear to be a fast
link that connects Europe and Asia. So traffic always goes through the US. Mumbai is closer geographically
to Netherlands than Oregon yet it has doubled the latency. The key message of this diagram is that
if your application is serving a global audience, you need to be
aware of network latency. If a user is waiting for a response,
350 milliseconds is very long. Your application will feel sluggish. Your user might even decide that
your application is down and abandon the request. One solution, is to deploy your
applications in multiple regions and use cross region load balancing. How to make that work is
the topic of this section. This is how the global https load balancer
implements cross region load balancing. In this example, you can see an application
deployed in two different regions. One region is US Central
one in Iowa North America. The other region is
Europe West one in Belgium. To make sure all clients experience
the best possible latency, you want to requests from clients in
Europe to go to the Belgian region and requests from clients in
the US to the region in Iowa. The front end in both regions
use the same ip address, and they use BGP,
border gateway protocol to exchange routing information with other
internet service providers ISPs. This makes sure requests from clients
reached a region that is closest to them in terms of network distance. There's also a reliability benefit from
using the global https load balancer because you're insulating
yourself from the possible, but very rare event of a cloud
run region failure. If that happens, google cloud forwards
requests from clients near the failing region to another region over
the internal google network. Be careful here. If cloud run is down in a region, the
request will get redirected, but if only your services down in a particular region,
the request will not get redirected. This is because right now there is no
support for end to end health checks. To understand how you can set up
across regional load balancing. We need to talk about the surveillance
network endpoint group or NEG. You learned earlier that a back end
service can be added to a URL map and a back end service has a back end. However, there is one additional layer
of abstraction you need to know about. The serverless products on google
cloud share one back end type called the serverless NEG. Think of the serverless network endpoint
group as an adapter piece you always need when you add app engine,
apps, cloud run services and cloud functions as a back end. Both the cloud run service and
the serverless NEG our regional resources, while the https load balancer and the back
end services, our global resources. To make the global load balancer route
requests to the closest back end, create multiple cloud run services
in the various regions you need and create a global ip
address in the front end. As of March 2021, one no http health
checks are supported for fail over. A fail over happens when cloud run
itself is failing in a region. This might have changed by the time
you have viewed this module. The cloud run services will have
separate deployment life cycles. If you are considering
a multi region architecture, you must consider that running cloud
run services in multiple regions and routing web request to the closest
region is the most transparent part. Most applications need to store and
retrieve data in order to be useful, and it's very likely that you want users in
one region to see the same data as users in other regions. If you use regional databases,
for example, using cloud SQL, it is challenging to make sure
the data is consistent across regions, especially if they are far
away from each other. One solution to this problem is to use
a multi regional database spanner is a distributed multi regional SQL database. It provides features such
as global transactions and strongly consistent reads. If you don't need a relational database,
there are other alternatives, and we'll look at some of them more closely
in a later module of this course.